import React from 'react'
// ===================================================================== Temp
import SearchForm from '#cpt/temp/SearchForm'
import Table from '#cpt/temp/Table'
import TableControls from '#cpt/temp/TableControls'
import Controls from '#cpt/temp/Controls'
// ===================================================================== global declare
const { $fn, $Lazy } = window
// ===================================================================== Lazy
const Page 		= $Lazy.load(()=>import('#tp/page/page-container'))
// ===================================================================== component
class Index extends React.Component{
	state = {
		data:[],
		pag: {},
		// 搜索表单列表
		forms : [
			{ label: '条码号',		name: 'spec_code' }
		],
	}
	query = {}
	model = {}
	
	componentDidMount(){
		const hosp_id = $fn.query().uuid
		this.query.hosp_id = hosp_id
		this.fetch()
	}
	 
	
	// paging
	fetch = () => $fn.fetch.call(this,'kd-report-spec/lookReport',{isIndex:true})
	
	// 表单
	cols = [
		{ title: '条码号',			dataIndex: 'spec_code', 		...$fn.table.spec_code },
		{ title: '姓名', 			dataIndex: 'name', 				...$fn.table.name },
		{ title: '性别', 			dataIndex: 'sex_name', 			...$fn.table.sex },
		{ title: '年龄', 			dataIndex: 'age', 				...$fn.table.age },
		{ title: '医院名称', 		dataIndex: 'hosp_name', 		width:200 },
		{ title: '报告发布时间', 		dataIndex: 'report_at', 		...$fn.table.time },
		{ title: '状态', 			dataIndex: 'status_name', 		width:150 },
		TableControls.controls.call(this)
	]
	
	// 表格操作按钮
	table_controls = (text,{ spec_code }) => [
		TableControls.pushTo.call(this,'预览', `preview-report?spec_code=${spec_code}`),
	]
	
	// 操作按钮
	controls = () => [
		Controls.back.call(this ),   		// 返回
	]
	
	render(){
		return (
			<>
				<Page title='查看报告' controls={this.controls()}>
					{/* 搜索 */}
					{ SearchForm.call(this) }
					{/* 表格 */}
					{ Table.call(this,{isIndex:true}) }
				</Page>
			</>
		)
	}
}

export default Index